<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增学生')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-student-add">

            <input name="studentId" type="hidden">
<!--            <input name="jiaoyujuId" class="form-control" type="hidden">-->
<!--            <input name="jituanxiaoId" class="form-control" type="hidden">-->
<!--            <input name="schoolId" class="form-control" type="hidden">-->

            <div class="form-group">
                <label class="col-sm-3 control-label">教育局：</label>
                <div class="col-sm-8">
                    <select id="jiaoyujuId" name="jiaoyujuId" class="form-control" required>
                        <option value="">请选择教育局</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">集团校：</label>
                <div class="col-sm-8">
                    <select id="jituanxiaoId" name="jituanxiaoId" class="form-control" required>
                        <option value="">请选择集团校</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">学校：</label>
                <div class="col-sm-8">
                    <select id="schoolId" name="schoolId" class="form-control" required>
                        <option value="">请选择学校</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">年级：</label>
                <div class="col-sm-8">
                    <select name="nianji" class="form-control" required>
                        <option value="">请选择年级</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">班级：</label>
                <div class="col-sm-8">
                    <select name="banji" class="form-control" required>
                        <option value="">请选择班级</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                        <option value="24">24</option>
                        <option value="25">25</option>
                        <option value="26">26</option>
                        <option value="27">27</option>
                        <option value="28">28</option>
                        <option value="29">29</option>
                        <option value="30">30</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">姓名：</label>
                <div class="col-sm-8">
                    <textarea name="name" class="form-control" rows="10" required placeholder="一行一个姓名"></textarea>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "typing/student"
        $("#form-student-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/batchAdd", $('#form-student-add').serialize());
            }
        }

        function listJiaoyuju() {
            $.ajax({
              type: 'POST',
              url: prefix + "/listSysDept",
              contentType : "application/json",
              dataType:'json',
              data: JSON.stringify({parentId:100}),
              success: function(result){
                    $.each(result, function(key, jiaoyuju) {
                        var option = '<option value="'+jiaoyuju.deptId+'">' + jiaoyuju.deptName + '</option>'      
                        $("#jiaoyujuId").append(option)
                    })
              }
            });
        }

        $().ready(function(){
            listJiaoyuju();
            $("#jiaoyujuId").change(function(){
                $.ajax({
                    type: 'POST',
                    url: prefix + "/listSysDept",
                    contentType : "application/json",
                    dataType:'json',
                    data: JSON.stringify({parentId:$("#jiaoyujuId").val()}),
                    success: function(result){
                        $.each(result, function(key, jituanxiao) {
                            var option = '<option value="'+jituanxiao.deptId+'">' + jituanxiao.deptName + '</option>'      
                            $("#jituanxiaoId").append(option)
                        })
                    }
                });
            });
            $("#jituanxiaoId").change(function(){
                $.ajax({
                    type: 'POST',
                    url: prefix + "/listSysDept",
                    contentType : "application/json",
                    dataType:'json',
                    data: JSON.stringify({parentId:$("#jituanxiaoId").val()}),
                    success: function(result){
                        $.each(result, function(key, school) {
                            var option = '<option value="'+school.deptId+'">' + school.deptName + '</option>'      
                            $("#schoolId").append(option)
                        })
                    }
                });
            });
        });
    </script>
</body>
</html>